<script setup>

import {ref} from "vue";
import axios from "axios";
import router from "@/assets/myRouter.js"

const accountBean = ref({});

const login = () => {
  axios.post('/server/login', accountBean.value)
    .then(resp => {
      const result = resp.data;
      confirm(result.msg)
      if (result.code === 200){
        //跳转登录页面
        router.push("/")
      }
    })
}
</script>

<template>
  <div>
    <div>
      <input v-model="accountBean.username">
    </div>
    <div>
      <input v-model="accountBean.password" type="password">
    </div>
    <div>
      <button @click="login">登录</button> <RouterLink to="/toRegister">去注册</RouterLink>
    </div>
  </div>

</template>

<style scoped>

</style>